package com.internal.dispatcher.thread;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;

import org.springframework.beans.factory.annotation.Autowired;





public class DispatcherThread {
	
	@Autowired
	private org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor taskExecutor;
	private SpiderRunnable run;
	private Object result;

	
	public void execute(Callable<Object> task) throws InterruptedException, ExecutionException{
		java.util.concurrent.Future<Object> fut = taskExecutor.submit(task);
		this.setResult(fut.get());
	}

	public void stop(){
		taskExecutor.shutdown();
	}
	
	public org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor getTaskExecutor() {
		return taskExecutor;
	}



	public void setTaskExecutor(
			org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor taskExecutor) {
		this.taskExecutor = taskExecutor;
	}


	public SpiderRunnable getRun() {
		return run;
	}


	public void setRun(SpiderRunnable run) {
		this.run = run;
	}

	public Object getResult() {
		return result;
	}

	public void setResult(Object result) {
		this.result = result;
	}

}
